package com.loongtech.bi.manager.report;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.loongtech.bi.action.PageHelper;
import com.loongtech.bi.action.UIHelper;
import com.loongtech.bi.entity.pay.EntityNewUserLTVTag;
import com.loongtech.bi.entity.pay.EntityPayUserTag;
import com.loongtech.bi.entity.pay.EntityTotalCashTag;
import com.loongtech.bi.entity.player.*;
import com.loongtech.bi.manager.pay.NewUserLTVManager;
import com.loongtech.bi.manager.pay.PayUserManager;
import com.loongtech.bi.manager.pay.TotalCashManager;
import com.loongtech.bi.manager.player.DaPlayTimeManager;
import com.loongtech.bi.manager.player.DauManager;
import com.loongtech.bi.manager.player.LeftManager;
import com.loongtech.bi.manager.player.NewUserManager;
import com.loongtech.bi.manager.system.BiPlatformManager;
import com.loongtech.bi.support.Helper;
import com.loongtech.bi.support.chart.ChartData1;
import com.loongtech.bi.support.chart.ChartFlow;
import com.loongtech.bi.support.chart.ChartSelect;
import com.loongtech.core.jpa.manager.ManagerQueryCacheBase;
import com.loongtech.core.util.Time;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;
import java.util.Map.Entry;

/**
 * Author: yuri
 * Description: 运营报表-国家区服
 * Date: 12:08 2017/6/26
 */
@Service
public class CountryServerReportManager extends ManagerQueryCacheBase<Object> {
    private static final long serialVersionUID = 1L;

    @Resource
    private NewUserManager newUserManager;
    @Resource
    private LeftManager leftManager;
    @Resource
    private DauManager dauManager;
    @Resource
    private DaPlayTimeManager daPlayTimeManager;
    @Resource
    private TotalCashManager totalCashManager;
    @Resource
    private PayUserManager payUserManager;
    @Resource
    private NewUserLTVManager newUserLTVManager;

    /**
     * 得到符合条件的所有数据
     */
    public List<GameReportData> getCountryServerReportData(String serverId, Date dateStart, Date dateEnd) {
        Map<String, GameReportData> tmpGRMap = new LinkedHashMap<>(); // key=country+date

        // 新增帐号
        List<EntityNewUserTag> list = newUserManager.getNewUsersByDateByTag(serverId, dateStart, dateEnd);
        if (!Helper.isEmptyValue(list)) {
            for (EntityNewUserTag o : list) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(Time.getDateStr(o.getDay()));
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setNewUser(o.getNew_user());
                int d = Time.getInterval(o.getDay(), new Date()) + 1;
                tmp.setTheLtvNewUser(d, o.getNew_user());
            }
        }

        // 留存
        List<EntitySecondLeftTag> list1 = leftManager.getLeftByDateByTag(serverId, dateStart, dateEnd, EntitySecondLeftTag.class);
        if (!Helper.isEmptyValue(list1)) {
            for (EntitySecondLeftTag o : list1) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(Time.getDateStr(o.getDay()));
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setThe2Left(o.getUser_left_rate());
                tmp.setThe2LeftLoginusernum(o.getLoginusernum());
                tmp.setThe2LeftUsercreatenum(o.getUsercreatenum());
            }
        }
        List<EntityThirdLeftTag> list2 = leftManager.getLeftByDateByTag(serverId, dateStart, dateEnd, EntityThirdLeftTag.class);
        if (!Helper.isEmptyValue(list2)) {
            for (EntityThirdLeftTag o : list2) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(Time.getDateStr(o.getDay()));
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setThe3Left(o.getUser_left_rate());
                tmp.setThe3LeftLoginusernum(o.getLoginusernum());
                tmp.setThe3LeftUsercreatenum(o.getUsercreatenum());
            }
        }
        List<EntitySevenLeftTag> list3 = leftManager.getLeftByDateByTag(serverId, dateStart, dateEnd, EntitySevenLeftTag.class);
        if (!Helper.isEmptyValue(list3)) {
            for (EntitySevenLeftTag o : list3) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(Time.getDateStr(o.getDay()));
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setThe7Left(o.getUser_left_rate());
                tmp.setThe7LeftLoginusernum(o.getLoginusernum());
                tmp.setThe7LeftUsercreatenum(o.getUsercreatenum());
            }
        }
        List<EntityFourteenLeftTag> list4 = leftManager.getLeftByDateByTag(serverId, dateStart, dateEnd, EntityFourteenLeftTag.class);
        if (!Helper.isEmptyValue(list4)) {
            for (EntityFourteenLeftTag o : list4) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(Time.getDateStr(o.getDay()));
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setThe14Left(o.getUser_left_rate());
                tmp.setThe14LeftLoginusernum(o.getLoginusernum());
                tmp.setThe14LeftUsercreatenum(o.getUsercreatenum());
            }
        }
        List<EntityMonthLeftTag> list5 = leftManager.getLeftByDateByTag(serverId, dateStart, dateEnd, EntityMonthLeftTag.class);
        if (!Helper.isEmptyValue(list5)) {
            for (EntityMonthLeftTag o : list5) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(Time.getDateStr(o.getDay()));
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setThe30Left(o.getUser_left_rate());
                tmp.setThe30LeftLoginusernum(o.getLoginusernum());
                tmp.setThe30LeftUsercreatenum(o.getUsercreatenum());
            }
        }

        // 分日活跃帐号数
        List<EntityDauTag> list7 = dauManager.getDauByDateByTag(serverId, dateStart, dateEnd);
        if (!Helper.isEmptyValue(list7)) {
            for (EntityDauTag o : list7) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(o.getStartday());
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setActiveUserCountByDay(o.getDau());
            }
        }

        // 活跃帐号总数
        List<EntityDauTag> list71 = dauManager.getAllDauByDateByTag(serverId, dateStart, dateEnd);
        if (!Helper.isEmptyValue(list71)) {
            for (EntityDauTag o : list71) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(o.getStartday());
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setActiveUserCount(o.getDau());
            }
        }

        // 人均在线时长(m)
        List<EntityDaPlayTimeTag> list8 = daPlayTimeManager.getDaPlayTimeByDateByTag(serverId, dateStart, dateEnd);
        if (!Helper.isEmptyValue(list8)) {
            for (EntityDaPlayTimeTag o : list8) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(Time.getDateStr(o.getDay()));
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setSumplaytime(o.getSumplaytime());
                tmp.setUseridnum(o.getUseridnum());
                tmp.setAvgOnlineTime((int) o.getDa_playtime());
            }
        }

        // 付费金额
        List<EntityTotalCashTag> list9 = totalCashManager.getTotalCashByDate(serverId, dateStart, dateEnd);
        if (!Helper.isEmptyValue(list9)) {
            for (EntityTotalCashTag o : list9) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(Time.getDateStr(o.getDay()));
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setPayCount(UIHelper.getYuan(o.getTotal_cash()));
            }
        }

        // 分日付费帐号数
        List<EntityPayUserTag> list10 = payUserManager.getPayUserByDateByTag(serverId, dateStart, dateEnd);
        if (!Helper.isEmptyValue(list10)) {
            for (EntityPayUserTag o : list10) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(o.getStartday());
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setPayUserCountByDay(o.getAddcash_user());
                // 活跃付费率
                tmp.setActivePayRadio(tmp.getActiveUserCountByDay() == 0 ? 0 : (float) (tmp.getPayUserCountByDay() * 1.0 / tmp.getActiveUserCountByDay()));

                // 付费ARPU
                tmp.setPayARPU(tmp.getPayUserCountByDay() == 0 ? 0 : PageHelper.floatKeepTwoNumber(tmp.getPayCount() * 1.0 / tmp.getPayUserCountByDay()));

                // 活跃ARPU
                tmp.setActiveARPU(tmp.getActiveUserCountByDay() == 0 ? 0 : PageHelper.floatKeepTwoNumber(tmp.getPayCount() * 1.0 / tmp.getActiveUserCountByDay()));
            }
        }

        // 付费账号总数
        List<EntityPayUserTag> list12 = payUserManager.getAllPayUserByDateByTag(serverId, dateStart, dateEnd);
        if (!Helper.isEmptyValue(list12)) {
            for (EntityPayUserTag o : list12) {
                String key = o.getKey();
                GameReportData tmp = tmpGRMap.get(key);
                if (tmp == null) {
                    tmp = new GameReportData();
                    tmp.setDateStr(o.getStartday());
                    tmp.setPlatformId(o.getPlatformid());
                    tmp.setChannelId(o.getChannelid());
                    tmp.setServerId(serverId);
                    tmp.setTagvalue(o.getTagvalue());
                    tmpGRMap.put(key, tmp);
                }
                tmp.setPayUserCount(o.getAddcash_user());
            }
        }

        // LTV
        List<EntityNewUserLTVTag> list13 = newUserLTVManager.getAllNewUserLTVByDateByTag(serverId, dateStart, dateEnd);
        if (!Helper.isEmptyValue(list13)) {
            for (EntityNewUserLTVTag o : list13) {
                int d = Time.getInterval(Time.formatDate(o.getStartday(), "yyyy-MM-dd"), Time.formatDate(o.getEndday(), "yyyy-MM-dd")) + 1;  // 充值日与创建日相差天数
                if (d == 7 || d == 14 || d == 30) {
                    String key = o.getKey();
                    GameReportData tmp = tmpGRMap.get(key);
                    if (tmp == null) {
                        tmp = new GameReportData();
                        tmp.setDateStr(o.getStartday());
                        tmp.setPlatformId(o.getPlatformid());
                        tmp.setChannelId(o.getChannelid());
                        tmp.setServerId(serverId);
                        tmp.setTagvalue(o.getTagvalue());
                        tmpGRMap.put(key, tmp);
                    }
                    tmp.setThePayUser(d, UIHelper.getYuan(o.getCashadd()));
                    tmp.setTheLTV(d, UIHelper.getYuan(o.getCashadd()));
                }
            }
        }
        return new ArrayList<>(tmpGRMap.values());
    }

    public List<GameReportData> updateData(List<GameReportData> allData) {
        Map<String, List<GameReportData>> countryDataMap = new HashMap<>(); // 国家辅助map
        for (GameReportData oa : allData) {
            List<GameReportData> oal1 = countryDataMap.get(oa.getTagvalue());
            if (oal1 == null) {
                oal1 = new ArrayList<>();
                countryDataMap.put(oa.getTagvalue(), oal1);
            }
            oal1.add(oa);
        }
        List<GameReportData> countryDataList = new ArrayList<>();
        // 组装国家数据
        for (Entry<String, List<GameReportData>> entry : countryDataMap.entrySet()) {
            List<GameReportData> value = entry.getValue();
            Collections.sort(value, new GameReportData().comparatorDate);
            GameReportData oa = new GameReportData();
//            oa.setTogglerDatas(value);//每日详细数据，需要再开
            oa.setTagvalue(entry.getKey());
            for (GameReportData o : value) {
                oa.setNewDevice(oa.getNewDevice() + o.getNewDevice());
                oa.setNewUser(oa.getNewUser() + o.getNewUser());
                oa.setActiveDevice(oa.getActiveDevice() + o.getActiveDevice());
                oa.setThe2LeftLoginusernum(oa.getThe2LeftLoginusernum() + o.getThe2LeftLoginusernum());
                oa.setThe2LeftUsercreatenum(oa.getThe2LeftUsercreatenum() + o.getThe2LeftUsercreatenum());
                oa.setThe3LeftLoginusernum(oa.getThe3LeftLoginusernum() + o.getThe3LeftLoginusernum());
                oa.setThe3LeftUsercreatenum(oa.getThe3LeftUsercreatenum() + o.getThe3LeftUsercreatenum());
                oa.setThe7LeftLoginusernum(oa.getThe7LeftLoginusernum() + o.getThe7LeftLoginusernum());
                oa.setThe7LeftUsercreatenum(oa.getThe7LeftUsercreatenum() + o.getThe7LeftUsercreatenum());
                oa.setThe14LeftLoginusernum(oa.getThe14LeftLoginusernum() + o.getThe14LeftLoginusernum());
                oa.setThe14LeftUsercreatenum(oa.getThe14LeftUsercreatenum() + o.getThe14LeftUsercreatenum());
                oa.setThe30LeftLoginusernum(oa.getThe30LeftLoginusernum() + o.getThe30LeftLoginusernum());
                oa.setThe30LeftUsercreatenum(oa.getThe30LeftUsercreatenum() + o.getThe30LeftUsercreatenum());
                oa.setValidatedNewUser(oa.getValidatedNewUser() + o.getValidatedNewUser());
                oa.setLoginRadioAliveUserCount(oa.getLoginRadioAliveUserCount() + o.getLoginRadioAliveUserCount());
                oa.setThe1LoginUserNumOfSecondWeek(oa.getThe1LoginUserNumOfSecondWeek() + o.getThe1LoginUserNumOfSecondWeek());
                oa.setThe3LoginUserNumOfFirstWeek(oa.getThe3LoginUserNumOfFirstWeek() + o.getThe3LoginUserNumOfFirstWeek());
                oa.setActiveUserCount(oa.getActiveUserCount() + o.getActiveUserCount());
                oa.setSumplaytime(oa.getSumplaytime() + o.getSumplaytime());
                oa.setUseridnum(oa.getUseridnum() + o.getUseridnum());
                oa.setAvgOnlineTime(oa.getAvgOnlineTime() + o.getAvgOnlineTime());
                oa.setPayCount(oa.getPayCount() + o.getPayCount());
                oa.setPayUserCount(oa.getPayUserCount() + o.getPayUserCount());
                oa.setFirstPayUserCount(oa.getFirstPayUserCount() + o.getFirstPayUserCount());
                oa.setNewPayUserCount(oa.getNewPayUserCount() + o.getNewPayUserCount());
                oa.setNewUserPayCount(oa.getNewUserPayCount() + o.getNewUserPayCount());
                oa.setThe7ltvNewUser(oa.getThe7ltvNewUser() + o.getThe7ltvNewUser());
                oa.setThe14ltvNewUser(oa.getThe14ltvNewUser() + o.getThe14ltvNewUser());
                oa.setThe30ltvNewUser(oa.getThe30ltvNewUser() + o.getThe30ltvNewUser());
                oa.setThePayUser(7, oa.getThe7PayUser() + o.getThe7PayUser());
                oa.setThePayUser(14, oa.getThe14PayUser() + o.getThe14PayUser());
                oa.setThePayUser(30, oa.getThe30PayUser() + o.getThe30PayUser());
            }
            countryDataList.add(oa);
        }
        int sumNewUser = 0, sumCash = 0;
        for (GameReportData tt : countryDataList) {
            sumNewUser = tt.getNewUser() + sumNewUser;
            sumCash = tt.getPayCount() + sumCash;
            tt.setThe2Left(tt.getThe2LeftUsercreatenum() == 0 ? 0 : (float) (tt.getThe2LeftLoginusernum() * 1.0 / tt.getThe2LeftUsercreatenum()));
            tt.setThe3Left(tt.getThe3LeftUsercreatenum() == 0 ? 0 : (float) (tt.getThe3LeftLoginusernum() * 1.0 / tt.getThe3LeftUsercreatenum()));
            tt.setThe7Left(tt.getThe7LeftUsercreatenum() == 0 ? 0 : (float) (tt.getThe7LeftLoginusernum() * 1.0 / tt.getThe7LeftUsercreatenum()));
            tt.setThe14Left(tt.getThe14LeftUsercreatenum() == 0 ? 0 : (float) (tt.getThe14LeftLoginusernum() * 1.0 / tt.getThe14LeftUsercreatenum()));
            tt.setThe30Left(tt.getThe30LeftUsercreatenum() == 0 ? 0 : (float) (tt.getThe30LeftLoginusernum() * 1.0 / tt.getThe30LeftUsercreatenum()));
            tt.setLoginNewUservalidatedRadio(tt.getNewUser() == 0 ? 0 : (float) (tt.getValidatedNewUser() * 1.0 / tt.getNewUser()));
            tt.setLoginRadio(tt.getValidatedNewUser() == 0 ? 0 : (float) (tt.getLoginRadioAliveUserCount() * 1.0 / tt.getValidatedNewUser()));
            tt.setLoginRadio2(tt.getThe3LoginUserNumOfFirstWeek() == 0 ? 0 : (float) (tt.getThe1LoginUserNumOfSecondWeek() * 1.0 / tt.getThe3LoginUserNumOfFirstWeek()));
            tt.setAvgOnlineTime((int) (tt.getAvgOnlineTime() * 1.0 / 60));
            tt.setActivePayRadio((float) ((tt.getPayUserCount()) * 1.0 / (tt.getActiveUserCount() == 0 ? 1 : tt.getActiveUserCount())));
            tt.setPayCount(tt.getPayCount());
            tt.setPayARPU(tt.getPayUserCount() == 0 ? 0 : PageHelper.floatKeepTwoNumber(tt.getPayCount() * 1.0 / tt.getPayUserCount()));
            tt.setActiveARPU(tt.getActiveUserCount() == 0 ? 0 : PageHelper.floatKeepTwoNumber(tt.getPayCount() * 1.0 / tt.getActiveUserCount()));
            tt.setTheLTV(7, tt.getThe7PayUser());
            tt.setTheLTV(14, tt.getThe14PayUser());
            tt.setTheLTV(30, tt.getThe30PayUser());
            tt.setNewUserPayRatio((float) (0.0)); // TODO
            tt.setNewPayUserARPU(0); // TODO
        }
        //计算新增整体占比，付费整体占比
        for (GameReportData tt : countryDataList) {
            tt.setNewUserAccount(sumNewUser == 0 ? 0 : PageHelper.floatKeepTwoNumber(tt.getNewUser() * 1.0 / sumNewUser));
            tt.setPayAccout(sumCash == 0 ? 0 : PageHelper.floatKeepTwoNumber(tt.getPayCount() * 1.0 / sumCash));
        }
        Collections.sort(countryDataList, new GameReportData().comparatorTagValue);
        return countryDataList;
    }


    // 前端数据类，饼状图数据类
    @JsonIgnoreProperties({"comparatorDate","comparatorServer","comparatorPlatformId","comparatorTagValue","comparatorPlatformName","comparatorChannelName","comparatorServerName"})
    public class GameReportData {
        private String platformId;
        private String channelId;
        private String serverId;
        private String tagvalue;
        @ChartFlow(name = "渠道")
        private String channelName;
        private String dateStr; // 日期

        private String serverTypeName = "";

        private int newDevice; // 新增设备数
        private int activeDevice; // 激活设备数
        @ChartSelect(name = "新增帐号", key = 1)
        @ChartData1(name = "新增帐号", key = 1)
        private int newUser; // 新增帐号数
        private float newUserAccount;// 新增整体占比
        private int distinctNewUser; // 排重新增帐号数
        private int the7ltvNewUser;  // 7日ltv新增帐号数
        private int the14ltvNewUser;  // 14日ltv新增帐号数
        private int the30ltvNewUser;  // 30日ltv新增帐号数
        private float the2Left; // 新增帐号次日留存率
        private int the2LeftLoginusernum; // 次日登录数，次日留存的分子
        private int the2LeftUsercreatenum; // 次日创建数，次日留存的分母
        private float the3Left; // 新增帐号3日留存率
        private int the3LeftLoginusernum; // 次日登录数，3日留存的分子
        private int the3LeftUsercreatenum; // 次日创建数，3日留存的分母
        private float the7Left; // 新增帐号7日留存率
        private int the7LeftLoginusernum; // 次日登录数，7日留存的分子
        private int the7LeftUsercreatenum; // 次日创建数，7日留存的分母
        private float the14Left; // 新增帐号14日留存率
        private int the14LeftLoginusernum; // 次日登录数，14日留存的分子
        private int the14LeftUsercreatenum; // 次日创建数，14日留存的分母
        private float the30Left; // 新增帐号30日留存率
        private int the30LeftLoginusernum; // 次日登录数，30日留存的分子
        private int the30LeftUsercreatenum; // 次日创建数，30日留存的分母
        private int validatedNewUser; // 有效新增用户数
        private float loginNewUservalidatedRadio; // 登录比新增用户有效率
        private int loginRadioAliveUserCount; // 一阶登录比留存用户数
        private float loginRadio; // 一阶登录比。loginNewUservalidatedRadio / validatedNewUser
        private int the3LoginUserNumOfFirstWeek;  // 首周登录三天用户数
        private int the1LoginUserNumOfSecondWeek;  // 次周登录过的用户数
        private float loginRadio2; // 二阶登录比. the1LoginUserNumOfSecondWeek / the3LoginUserNumOfFirstWeek
        @ChartSelect(name = "活跃帐号", key = 2)
        @ChartData1(name = "活跃帐号", key = 2)
        private int activeUserCount; // 活跃账号总数
        private int activeUserCountByDay;  // 单日活跃帐号数
        private int avgOnlineTime; // 人均在线时长(m)
        private long sumplaytime; // 在线总时长
        private long useridnum; // 在线总人数
        @ChartSelect(name = "付费金额", key = 3)
        @ChartData1(name = "付费金额", key = 3)
        private int payCount; // 付费金额
        private int payUserCount; // 付费账号数
        private float payAccout; //付费整体占比
        private int payUserCountByDay; // 单日付费账号数
        private int firstPayUserCount; // 首次付费账号数
        private float activePayRadio; // 活跃付费率
        private float payARPU; // 付费ARPU
        private float activeARPU; // 活跃ARPU
        private int newPayUserCount; // 新增账号付费人数
        private int newUserPayCount; // 新增账号付费金额
        private float newUserPayRatio; // 新增账号付费率
        private float newPayUserARPU; // 新增账号付费ARPU
        private int the7PayUser;  // 7日付费
        private int the14PayUser;  // 14日付费
        private int the30PayUser;  // 30日付费
        private float the7LTV; // 7日LTV
        private float the14LTV; // 14日LTV
        private float the30LTV; // 30日LTV

        private List<GameReportData> togglerDatas; // 点击扩展显示的数据

        // 根据日期排序的比较器
        public final Comparator<GameReportData> comparatorDate = new Comparator<GameReportData>() {
            public int compare(GameReportData s1, GameReportData s2) {
                return s2.getDateStr().compareTo(s1.getDateStr()); //(int) (Time.formatDateStr(s2.getDateStr(), "yyyy-MM-dd") - Time.formatDateStr(s1.getDateStr(), "yyyy-MM-dd"));
            }
        };

        // 根据serverid排序的比较器
        public final Comparator<GameReportData> comparatorServer = new Comparator<GameReportData>() {
            public int compare(GameReportData s1, GameReportData s2) {
                return s1.getServerId().compareTo(s2.getServerId());
            }
        };

        public final Comparator<GameReportData> comparatorPlatformId = new Comparator<GameReportData>() {
            public int compare(GameReportData s1, GameReportData s2) {
                if ("0".equals(s1.getPlatformId())) {
                    return 1;
                } else {
                    return -1;
                }
            }
        };

        public final Comparator<GameReportData> comparatorTagValue = new Comparator<GameReportData>() {
            public int compare(GameReportData s1, GameReportData s2) {
                return s1.getTagvalue().compareTo(s2.getTagvalue());
            }
        };

        public final Comparator<GameReportData> comparatorPlatformName = new Comparator<GameReportData>() {
            public int compare(GameReportData s1, GameReportData s2) {
                return BiPlatformManager.getPlatformNameById(s1.getPlatformId()).compareTo(BiPlatformManager.getPlatformNameById(s2.getPlatformId()));
            }
        };

        public final Comparator<GameReportData> comparatorChannelName = new Comparator<GameReportData>() {
            public int compare(GameReportData s1, GameReportData s2) {
                return BiPlatformManager.getChannelNameById(s1.getChannelId()).compareTo(BiPlatformManager.getChannelNameById(s2.getChannelId()));
            }
        };

        public final Comparator<GameReportData> comparatorServerName = new Comparator<GameReportData>() {
            public int compare(GameReportData s1, GameReportData s2) {
                return BiPlatformManager.getServerNameById(s1.getServerId()).compareTo(BiPlatformManager.getServerNameById(s2.getServerId()));
            }
        };
//
//        // 是不是总体数据（）
//        public boolean isAllData() {
//            return "0".equals(platformId) && "0".equals(channelId) && "0".equals(serverId);
//        }

        public void setTheLtvNewUser(int d, int newUser) {
            if (d >= 7) {
                the7ltvNewUser = newUser;
            }
            if (d >= 14) {
                the14ltvNewUser = newUser;
            }
            if (d >= 30) {
                the30ltvNewUser = newUser;
            }
        }

        public void setThePayUser(int d, int payUser) {
            if (d == 7) {
                the7PayUser = payUser;
            } else if (d == 14) {
                the14PayUser = payUser;
            } else if (d == 30) {
                the30PayUser = payUser;
            }
        }

        public void setTheLTV(int d, int cashadd) {
            if (d == 7) {
                the7LTV = PageHelper.floatKeepTwoNumber(the7ltvNewUser == 0 ? 0 : (float) (cashadd * 1.0 / the7ltvNewUser));
            } else if (d == 14) {
                the14LTV = PageHelper.floatKeepTwoNumber(the14ltvNewUser == 0 ? 0 : (float) (cashadd * 1.0 / the14ltvNewUser));
            } else if (d == 30) {
                the30LTV = PageHelper.floatKeepTwoNumber(the30ltvNewUser == 0 ? 0 : (float) (cashadd * 1.0 / the30ltvNewUser));
            }
        }

        public float getNewUserAccount() {
            return newUserAccount;
        }

        public void setNewUserAccount(float newUserAccount) {
            this.newUserAccount = newUserAccount;
        }

        public float getPayAccout() {
            return payAccout;
        }

        public void setPayAccout(float payAccout) {
            this.payAccout = payAccout;
        }

        public int getActiveDevice() {
            return activeDevice;
        }

        public void setActiveDevice(int activeDevice) {
            this.activeDevice = activeDevice;
        }

        public String getPlatformId() {
            return platformId;
        }

        public void setPlatformId(String platformId) {
            this.platformId = platformId;
        }

        public String getChannelId() {
            return channelId;
        }

        public void setChannelId(String channelId) {
            this.channelId = channelId;
            this.channelName = BiPlatformManager.getChannelNameById(channelId);
        }

        public String getTagvalue() {
            return tagvalue;
        }

        public void setTagvalue(String tagvalue) {
            this.tagvalue = tagvalue;
        }

        public String getServerId() {
            return serverId;
        }

        public void setServerId(String serverId) {
            this.serverId = serverId;
        }

        public String getChannelName() {
            return channelName;
        }

        public void setChannelName(String channelName) {
            this.channelName = channelName;
        }

        public String getDateStr() {
            return dateStr;
        }

        public void setDateStr(String dateStr) {
            this.dateStr = dateStr;
        }

        public int getNewDevice() {
            return newDevice;
        }

        public void setNewDevice(int newDevice) {
            this.newDevice = newDevice;
        }

        public int getNewUser() {
            return newUser;
        }

        public void setNewUser(int newUser) {
            this.newUser = newUser;
        }

        public int getDistinctNewUser() {
            return distinctNewUser;
        }

        public void setDistinctNewUser(int distinctNewUser) {
            this.distinctNewUser = distinctNewUser;
        }

        public float getThe2Left() {
            return the2Left;
        }

        public void setThe2Left(float the2Left) {
            this.the2Left = the2Left;
        }

        public float getThe3Left() {
            return the3Left;
        }

        public void setThe3Left(float the3Left) {
            this.the3Left = the3Left;
        }

        public float getThe7Left() {
            return the7Left;
        }

        public void setThe7Left(float the7Left) {
            this.the7Left = the7Left;
        }

        public float getThe14Left() {
            return the14Left;
        }

        public void setThe14Left(float the14Left) {
            this.the14Left = the14Left;
        }

        public float getThe30Left() {
            return the30Left;
        }

        public void setThe30Left(float the30Left) {
            this.the30Left = the30Left;
        }

        public int getValidatedNewUser() {
            return validatedNewUser;
        }

        public void setValidatedNewUser(int validatedNewUser) {
            this.validatedNewUser = validatedNewUser;
        }

        public float getLoginNewUservalidatedRadio() {
            return loginNewUservalidatedRadio;
        }

        public void setLoginNewUservalidatedRadio(float loginNewUservalidatedRadio) {
            this.loginNewUservalidatedRadio = loginNewUservalidatedRadio;
        }

        public int getLoginRadioAliveUserCount() {
            return loginRadioAliveUserCount;
        }

        public void setLoginRadioAliveUserCount(int loginRadioAliveUserCount) {
            this.loginRadioAliveUserCount = loginRadioAliveUserCount;
        }

        public float getLoginRadio() {
            return loginRadio;
        }

        public void setLoginRadio(float loginRadio) {
            this.loginRadio = loginRadio;
        }

        public int getActiveUserCount() {
            return activeUserCount;
        }

        public void setActiveUserCount(int activeUserCount) {
            this.activeUserCount = activeUserCount;
        }

        public int getAvgOnlineTime() {
            return avgOnlineTime;
        }

        public void setAvgOnlineTime(int avgOnlineTime) {
            this.avgOnlineTime = avgOnlineTime;
        }

        public int getPayCount() {
            return payCount;
        }

        public void setPayCount(int payCount) {
            this.payCount = payCount;
        }

        public int getPayUserCount() {
            return payUserCount;
        }

        public void setPayUserCount(int payUserCount) {
            this.payUserCount = payUserCount;
        }

        public int getFirstPayUserCount() {
            return firstPayUserCount;
        }

        public void setFirstPayUserCount(int firstPayUserCount) {
            this.firstPayUserCount = firstPayUserCount;
        }

        public float getActivePayRadio() {
            return activePayRadio;
        }

        public void setActivePayRadio(float activePayRadio) {
            this.activePayRadio = activePayRadio;
        }

        public float getPayARPU() {
            return payARPU;
        }

        public void setPayARPU(float payARPU) {
            this.payARPU = payARPU;
        }

        public float getActiveARPU() {
            return activeARPU;
        }

        public void setActiveARPU(float activeARPU) {
            this.activeARPU = activeARPU;
        }

        public int getNewPayUserCount() {
            return newPayUserCount;
        }

        public void setNewPayUserCount(int newPayUserCount) {
            this.newPayUserCount = newPayUserCount;
        }

        public int getNewUserPayCount() {
            return newUserPayCount;
        }

        public void setNewUserPayCount(int newUserPayCount) {
            this.newUserPayCount = newUserPayCount;
        }

        public float getNewUserPayRatio() {
            return newUserPayRatio;
        }

        public void setNewUserPayRatio(float newUserPayRatio) {
            this.newUserPayRatio = newUserPayRatio;
        }

        public float getNewPayUserARPU() {
            return newPayUserARPU;
        }

        public void setNewPayUserARPU(float newPayUserARPU) {
            this.newPayUserARPU = newPayUserARPU;
        }

        public float getThe7LTV() {
            return the7LTV;
        }

        public void setThe7LTV(float the7ltv) {
            the7LTV = the7ltv;
        }

        public float getThe14LTV() {
            return the14LTV;
        }

        public void setThe14LTV(float the14ltv) {
            the14LTV = the14ltv;
        }

        public float getThe30LTV() {
            return the30LTV;
        }

        public void setThe30LTV(float the30ltv) {
            the30LTV = the30ltv;
        }

        public int getThe2LeftLoginusernum() {
            return the2LeftLoginusernum;
        }

        public void setThe2LeftLoginusernum(int the2LeftLoginusernum) {
            this.the2LeftLoginusernum = the2LeftLoginusernum;
        }

        public int getThe2LeftUsercreatenum() {
            return the2LeftUsercreatenum;
        }

        public void setThe2LeftUsercreatenum(int the2LeftUsercreatenum) {
            this.the2LeftUsercreatenum = the2LeftUsercreatenum;
        }

        public int getThe3LeftLoginusernum() {
            return the3LeftLoginusernum;
        }

        public void setThe3LeftLoginusernum(int the3LeftLoginusernum) {
            this.the3LeftLoginusernum = the3LeftLoginusernum;
        }

        public int getThe3LeftUsercreatenum() {
            return the3LeftUsercreatenum;
        }

        public void setThe3LeftUsercreatenum(int the3LeftUsercreatenum) {
            this.the3LeftUsercreatenum = the3LeftUsercreatenum;
        }

        public int getThe7LeftLoginusernum() {
            return the7LeftLoginusernum;
        }

        public void setThe7LeftLoginusernum(int the7LeftLoginusernum) {
            this.the7LeftLoginusernum = the7LeftLoginusernum;
        }

        public int getThe7LeftUsercreatenum() {
            return the7LeftUsercreatenum;
        }

        public void setThe7LeftUsercreatenum(int the7LeftUsercreatenum) {
            this.the7LeftUsercreatenum = the7LeftUsercreatenum;
        }

        public int getThe14LeftLoginusernum() {
            return the14LeftLoginusernum;
        }

        public void setThe14LeftLoginusernum(int the14LeftLoginusernum) {
            this.the14LeftLoginusernum = the14LeftLoginusernum;
        }

        public int getThe14LeftUsercreatenum() {
            return the14LeftUsercreatenum;
        }

        public void setThe14LeftUsercreatenum(int the14LeftUsercreatenum) {
            this.the14LeftUsercreatenum = the14LeftUsercreatenum;
        }

        public int getThe30LeftLoginusernum() {
            return the30LeftLoginusernum;
        }

        public void setThe30LeftLoginusernum(int the30LeftLoginusernum) {
            this.the30LeftLoginusernum = the30LeftLoginusernum;
        }

        public int getThe30LeftUsercreatenum() {
            return the30LeftUsercreatenum;
        }

        public void setThe30LeftUsercreatenum(int the30LeftUsercreatenum) {
            this.the30LeftUsercreatenum = the30LeftUsercreatenum;
        }

        public long getSumplaytime() {
            return sumplaytime;
        }

        public void setSumplaytime(long sumplaytime) {
            this.sumplaytime = sumplaytime;
        }

        public long getUseridnum() {
            return useridnum;
        }

        public void setUseridnum(long useridnum) {
            this.useridnum = useridnum;
        }

        public List<GameReportData> getTogglerDatas() {
            return togglerDatas;
        }

        public void setTogglerDatas(List<GameReportData> togglerDatas) {
            this.togglerDatas = togglerDatas;
        }

        public int getActiveUserCountByDay() {
            return activeUserCountByDay;
        }

        public void setActiveUserCountByDay(int activeUserCountByDay) {
            this.activeUserCountByDay = activeUserCountByDay;
        }

        public int getPayUserCountByDay() {
            return payUserCountByDay;
        }

        public void setPayUserCountByDay(int payUserCountByDay) {
            this.payUserCountByDay = payUserCountByDay;
        }

        public int getThe7PayUser() {
            return the7PayUser;
        }

        public void setThe7PayUser(int the7PayUser) {
            this.the7PayUser = the7PayUser;
        }

        public int getThe14PayUser() {
            return the14PayUser;
        }

        public void setThe14PayUser(int the14PayUser) {
            this.the14PayUser = the14PayUser;
        }

        public int getThe30PayUser() {
            return the30PayUser;
        }

        public void setThe30PayUser(int the30PayUser) {
            this.the30PayUser = the30PayUser;
        }

        public int getThe7ltvNewUser() {
            return the7ltvNewUser;
        }

        public void setThe7ltvNewUser(int the7ltvNewUser) {
            this.the7ltvNewUser = the7ltvNewUser;
        }

        public int getThe14ltvNewUser() {
            return the14ltvNewUser;
        }

        public void setThe14ltvNewUser(int the14ltvNewUser) {
            this.the14ltvNewUser = the14ltvNewUser;
        }

        public int getThe30ltvNewUser() {
            return the30ltvNewUser;
        }

        public void setThe30ltvNewUser(int the30ltvNewUser) {
            this.the30ltvNewUser = the30ltvNewUser;
        }

        public String getServerTypeName() {
            return serverTypeName;
        }

        public void setServerTypeName(String serverTypeName) {
            this.serverTypeName = serverTypeName;
        }

        public float getLoginRadio2() {
            return loginRadio2;
        }

        public void setLoginRadio2(float loginRadio2) {
            this.loginRadio2 = loginRadio2;
        }

        public int getThe3LoginUserNumOfFirstWeek() {
            return the3LoginUserNumOfFirstWeek;
        }

        public void setThe3LoginUserNumOfFirstWeek(int the3LoginUserNumOfFirstWeek) {
            this.the3LoginUserNumOfFirstWeek = the3LoginUserNumOfFirstWeek;
        }

        public int getThe1LoginUserNumOfSecondWeek() {
            return the1LoginUserNumOfSecondWeek;
        }

        public void setThe1LoginUserNumOfSecondWeek(int the1LoginUserNumOfSecondWeek) {
            this.the1LoginUserNumOfSecondWeek = the1LoginUserNumOfSecondWeek;
        }
    }
}
